(function () {
    class Animal {
        name: string;
        age: number;
        constructor(name: string, age: number) {
            this.name = name;
            this.age = age;
        };
        sayHello() {
            console.log("动物叫~~~ ")
        }
    }

    class Dog extends Animal {
        home: string;
        /* 
        // 报错  如果在子类中写了constructor构造函数，相当于重写了父类的constructor构造函数
        // 子类构造函数必须对父类的构造函数进行调用 
        constructor(home: string) {
            this.home = home
        } 
        */
        constructor(name: string, age: number, home: string) {
            // 子类调用父类构造函数
            super(name, age);
            this.home = home
        }

        sayHello(): void {
            // 在类的方法中super就表示当前类的父类
            super.sayHello();  // 继承父类中的sayHello()方法
        }
    }

    // const myDog = new Dog("小黑", 2);
    const myDog = new Dog("小黑", 2, "地球");
    myDog.sayHello();

})()